<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Material filter form base class.
 *
 * @package    alika
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormFilterGeneratedTemplate.php 16976 2009-04-04 12:47:44Z fabien $
 */
class BaseMaterialFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'photo_path'        => new sfWidgetFormFilterInput(),
      'created_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'stat'              => new sfWidgetFormFilterInput(),
      'user_id'           => new sfWidgetFormPropelChoice(array('model' => 'sfGuardUser', 'add_empty' => true)),
      'content'           => new sfWidgetFormFilterInput(),
      'short_content'     => new sfWidgetFormFilterInput(),
      'title'             => new sfWidgetFormFilterInput(),
      'seo_keyword'       => new sfWidgetFormFilterInput(),
      'seo_description'   => new sfWidgetFormFilterInput(),
      'seo_title'         => new sfWidgetFormFilterInput(),
      'link'              => new sfWidgetFormFilterInput(),
      'see'               => new sfWidgetFormFilterInput(),
      'click'             => new sfWidgetFormFilterInput(),
      'city'              => new sfWidgetFormFilterInput(),
      'country'           => new sfWidgetFormFilterInput(),
      'custom_int1'       => new sfWidgetFormFilterInput(),
      'custom_int2'       => new sfWidgetFormFilterInput(),
      'custom_int3'       => new sfWidgetFormFilterInput(),
      'custom_char1'      => new sfWidgetFormFilterInput(),
      'custom_char2'      => new sfWidgetFormFilterInput(),
      'custom_char3'      => new sfWidgetFormFilterInput(),
      'custom_text1'      => new sfWidgetFormFilterInput(),
      'custom_text2'      => new sfWidgetFormFilterInput(),
      'custom_text3'      => new sfWidgetFormFilterInput(),
      'custom_timestamp1' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'custom_timestamp2' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'custom_timestamp3' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'custom_date1'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'custom_date2'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'custom_date3'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'custom_file1'      => new sfWidgetFormFilterInput(),
      'custom_file2'      => new sfWidgetFormFilterInput(),
      'custom_file3'      => new sfWidgetFormFilterInput(),
      'custom_bool1'      => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'custom_bool2'      => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'custom_bool3'      => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'type_id'           => new sfWidgetFormPropelChoice(array('model' => 'TypeMaterial', 'add_empty' => true)),
      'type_char'         => new sfWidgetFormFilterInput(),
      'phone'             => new sfWidgetFormFilterInput(),
      'adres'             => new sfWidgetFormFilterInput(),
      'email'             => new sfWidgetFormFilterInput(),
      'parent_id'         => new sfWidgetFormPropelChoice(array('model' => 'Material', 'add_empty' => true)),
      'child_id'          => new sfWidgetFormPropelChoice(array('model' => 'Folder', 'add_empty' => true)),
      'folder_id'         => new sfWidgetFormFilterInput(),
      'region_id'         => new sfWidgetFormPropelChoice(array('model' => 'Region', 'add_empty' => true)),
      'pub'               => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'contact_fio'       => new sfWidgetFormFilterInput(),
      'contact_dolzhnost' => new sfWidgetFormFilterInput(),
      'contact_email'     => new sfWidgetFormFilterInput(),
      'contact_phone'     => new sfWidgetFormFilterInput(),
      'fax'               => new sfWidgetFormFilterInput(),
      'code_location'     => new sfWidgetFormFilterInput(),
      'navigation_folder' => new sfWidgetFormFilterInput(),
      'rating'            => new sfWidgetFormFilterInput(),
      'cost'              => new sfWidgetFormFilterInput(),
      'cant_delete'       => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'folders_array'     => new sfWidgetFormFilterInput(),
      'tag'               => new sfWidgetFormFilterInput(),
      'is_video'          => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'is_photo'          => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'is_file'           => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'is_news'           => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'folder2tag_list'   => new sfWidgetFormPropelChoice(array('model' => 'Folder', 'add_empty' => true)),
      'mat2_folder_list'  => new sfWidgetFormPropelChoice(array('model' => 'Folder', 'add_empty' => true)),
      'mat2tag_list'      => new sfWidgetFormPropelChoice(array('model' => 'Tag', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'photo_path'        => new sfValidatorPass(array('required' => false)),
      'created_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'stat'              => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'user_id'           => new sfValidatorPropelChoice(array('required' => false, 'model' => 'sfGuardUser', 'column' => 'id')),
      'content'           => new sfValidatorPass(array('required' => false)),
      'short_content'     => new sfValidatorPass(array('required' => false)),
      'title'             => new sfValidatorPass(array('required' => false)),
      'seo_keyword'       => new sfValidatorPass(array('required' => false)),
      'seo_description'   => new sfValidatorPass(array('required' => false)),
      'seo_title'         => new sfValidatorPass(array('required' => false)),
      'link'              => new sfValidatorPass(array('required' => false)),
      'see'               => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'click'             => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'city'              => new sfValidatorPass(array('required' => false)),
      'country'           => new sfValidatorPass(array('required' => false)),
      'custom_int1'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'custom_int2'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'custom_int3'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'custom_char1'      => new sfValidatorPass(array('required' => false)),
      'custom_char2'      => new sfValidatorPass(array('required' => false)),
      'custom_char3'      => new sfValidatorPass(array('required' => false)),
      'custom_text1'      => new sfValidatorPass(array('required' => false)),
      'custom_text2'      => new sfValidatorPass(array('required' => false)),
      'custom_text3'      => new sfValidatorPass(array('required' => false)),
      'custom_timestamp1' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'custom_timestamp2' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'custom_timestamp3' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'custom_date1'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'custom_date2'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'custom_date3'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'custom_file1'      => new sfValidatorPass(array('required' => false)),
      'custom_file2'      => new sfValidatorPass(array('required' => false)),
      'custom_file3'      => new sfValidatorPass(array('required' => false)),
      'custom_bool1'      => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'custom_bool2'      => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'custom_bool3'      => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'type_id'           => new sfValidatorPropelChoice(array('required' => false, 'model' => 'TypeMaterial', 'column' => 'id')),
      'type_char'         => new sfValidatorPass(array('required' => false)),
      'phone'             => new sfValidatorPass(array('required' => false)),
      'adres'             => new sfValidatorPass(array('required' => false)),
      'email'             => new sfValidatorPass(array('required' => false)),
      'parent_id'         => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Material', 'column' => 'id')),
      'child_id'          => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Folder', 'column' => 'id')),
      'folder_id'         => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'region_id'         => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Region', 'column' => 'id')),
      'pub'               => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'contact_fio'       => new sfValidatorPass(array('required' => false)),
      'contact_dolzhnost' => new sfValidatorPass(array('required' => false)),
      'contact_email'     => new sfValidatorPass(array('required' => false)),
      'contact_phone'     => new sfValidatorPass(array('required' => false)),
      'fax'               => new sfValidatorPass(array('required' => false)),
      'code_location'     => new sfValidatorPass(array('required' => false)),
      'navigation_folder' => new sfValidatorPass(array('required' => false)),
      'rating'            => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'cost'              => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'cant_delete'       => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'folders_array'     => new sfValidatorPass(array('required' => false)),
      'tag'               => new sfValidatorPass(array('required' => false)),
      'is_video'          => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'is_photo'          => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'is_file'           => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'is_news'           => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'folder2tag_list'   => new sfValidatorPropelChoice(array('model' => 'Folder', 'required' => false)),
      'mat2_folder_list'  => new sfValidatorPropelChoice(array('model' => 'Folder', 'required' => false)),
      'mat2tag_list'      => new sfValidatorPropelChoice(array('model' => 'Tag', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('material_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function addFolder2tagListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(Folder2tagPeer::MAT_ID, MaterialPeer::ID);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(Folder2tagPeer::FOLDER_ID, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(Folder2tagPeer::FOLDER_ID, $value));
    }

    $criteria->add($criterion);
  }

  public function addMat2FolderListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(Mat2FolderPeer::MATERIAL_ID, MaterialPeer::ID);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(Mat2FolderPeer::FOLDER_ID, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(Mat2FolderPeer::FOLDER_ID, $value));
    }

    $criteria->add($criterion);
  }

  public function addMat2tagListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(Mat2tagPeer::MAT_ID, MaterialPeer::ID);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(Mat2tagPeer::TAG_ID, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(Mat2tagPeer::TAG_ID, $value));
    }

    $criteria->add($criterion);
  }

  public function getModelName()
  {
    return 'Material';
  }

  public function getFields()
  {
    return array(
      'id'                => 'Number',
      'photo_path'        => 'Text',
      'created_at'        => 'Date',
      'updated_at'        => 'Date',
      'stat'              => 'Number',
      'user_id'           => 'ForeignKey',
      'content'           => 'Text',
      'short_content'     => 'Text',
      'title'             => 'Text',
      'seo_keyword'       => 'Text',
      'seo_description'   => 'Text',
      'seo_title'         => 'Text',
      'link'              => 'Text',
      'see'               => 'Number',
      'click'             => 'Number',
      'city'              => 'Text',
      'country'           => 'Text',
      'custom_int1'       => 'Number',
      'custom_int2'       => 'Number',
      'custom_int3'       => 'Number',
      'custom_char1'      => 'Text',
      'custom_char2'      => 'Text',
      'custom_char3'      => 'Text',
      'custom_text1'      => 'Text',
      'custom_text2'      => 'Text',
      'custom_text3'      => 'Text',
      'custom_timestamp1' => 'Date',
      'custom_timestamp2' => 'Date',
      'custom_timestamp3' => 'Date',
      'custom_date1'      => 'Date',
      'custom_date2'      => 'Date',
      'custom_date3'      => 'Date',
      'custom_file1'      => 'Text',
      'custom_file2'      => 'Text',
      'custom_file3'      => 'Text',
      'custom_bool1'      => 'Boolean',
      'custom_bool2'      => 'Boolean',
      'custom_bool3'      => 'Boolean',
      'type_id'           => 'ForeignKey',
      'type_char'         => 'Text',
      'phone'             => 'Text',
      'adres'             => 'Text',
      'email'             => 'Text',
      'parent_id'         => 'ForeignKey',
      'child_id'          => 'ForeignKey',
      'folder_id'         => 'Number',
      'region_id'         => 'ForeignKey',
      'pub'               => 'Boolean',
      'contact_fio'       => 'Text',
      'contact_dolzhnost' => 'Text',
      'contact_email'     => 'Text',
      'contact_phone'     => 'Text',
      'fax'               => 'Text',
      'code_location'     => 'Text',
      'navigation_folder' => 'Text',
      'rating'            => 'Number',
      'cost'              => 'Number',
      'cant_delete'       => 'Boolean',
      'folders_array'     => 'Text',
      'tag'               => 'Text',
      'is_video'          => 'Boolean',
      'is_photo'          => 'Boolean',
      'is_file'           => 'Boolean',
      'is_news'           => 'Boolean',
      'folder2tag_list'   => 'ManyKey',
      'mat2_folder_list'  => 'ManyKey',
      'mat2tag_list'      => 'ManyKey',
    );
  }
}
